﻿using Blog.Core.Domain.Model.User;
using Dapper;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Data.SqlClient;

namespace Blog.Core.Api.Dapper
{
    public class DapperHelp
    {
        private const string CONNECT_STRING = "Data Source=.;Initial Catalog=WEBVUE0617;Integrated Security=True";
        public static List<UserInfo> List()
        {
            using (var conn = new SqlConnection(CONNECT_STRING))
            {
                string sql = "Select * from UserInfo join (Select b.UserId from RoleUsers as b  join Roles as c on b.RoleId = c.Id )as d on UserInfo.Id = d.UserId";
                List<UserInfo> users = conn.Query<UserInfo>(sql).ToList();
                return users;
            }
        }
    }
}
